package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202409;

public class leetcode20240922 {
    public int findJudge(int n,int[][] trust){
        int[][] res=new int[n+1][2];// in out
        for(int i=0;i<trust.length;i++){
            res[trust[i][0]][0]++;// 信任别人的次数
            res[trust[i][1]][1]++;// 被信任的次数
        }
        for(int i=1;i<=n;i++){
            if(res[i][0]==0 && res[i][1]==n-1) return i;
        }
        return -1;
    }
}
